<?php
declare (strict_types=1);

namespace app\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class ReviewCase extends AppModel
{
    //审核状态
    const ONE_AUDIT_STATUS = 1;
    const TWO_AUDIT_STATUS = 2;

    //审核结果
    const ZERO_AUDIT_RESULT = 0;
    const ONE_AUDIT_RESULT = 1;
    const TWO_AUDIT_RESULT = 2;
    const THREE_AUDIT_RESULT = 3;
    const TOUR_AUDIT_RESULT = 4;

    //复查状态
    const ONE_REVIEW_STATUS = 1;
    const TWO_REVIEW_STATUS = 2;
    const THREE_REVIEW_STATUS = 3;


    /**
     * @var string[]
     * @User: 刘海龙
     * @Date: 2021/7/27
     * @Time: 8:52
     * 审核状态
     */
    public static $audit_status = array(
        self::ONE_AUDIT_STATUS => '未审核',
        self::TWO_AUDIT_STATUS => '已审核'
    );

    /**
     * @var string[]
     * @User: 刘海龙
     * @Date: 2021/7/27
     * @Time: 8:52
     * 审核结果
     */
    public static $audit_result  = array(
        self::ZERO_AUDIT_RESULT => '暂无结果',
        self::ONE_AUDIT_RESULT => '已整改',
        self::TWO_AUDIT_RESULT => '未整改',
        self::THREE_AUDIT_RESULT => '反弹',
        self::TOUR_AUDIT_RESULT => '不合格'
    );

    /**
     * @var string[]
     * @User: 刘海龙
     * @Date: 2021/7/27
     * @Time: 8:53
     * 复查状态
     */
    public static $review_status = array(
        self::ONE_REVIEW_STATUS => '未复查',
        self::TWO_REVIEW_STATUS => '已复查',
//        self::THREE_REVIEW_STATUS =>'不合格'
    );


    public function project()
    {
        return $this->belongsTo(ReviewProject::class, 'review_project_id');
    }

    public function sample()
    {
        return $this->belongsTo(Sample::class, 'new_sample_id');
    }

    public function admin(){
        return $this->belongsTo(Admin::class,'audit_people')->field('id,username');
    }


    public function unqualified(){
        return $this->hasOne(UnqualifiedCase::class,'review_case_id');
    }

    public function user(){
        return $this->belongsTo(User::class,'review_people')->field('id,username,mobile,community_id');
    }
}
